import request from '@/utils/request';

// 查询我的审批列表
export async function queryAuditPageList(params) {
  return request('/b/fileapply/queryAuditPageList', {
    method: 'POST',
    data: params,
  });
}

// 查询我的接收
export async function queryDownloadPageList(params) {
  return request('/b/fileinfo/queryDownloadPageList', {
    method: 'POST',
    data: params,
  });
}

// 下载我的接收
export async function downloadMyReceive(params) {
  return request('/api/login/account', {
    method: 'POST',
    data: params,
  });
}


// 删除我的接收
export async function deleteMyReceive(params) {
  return request('/api/login/account', {
    method: 'POST',
    data: params,
  });
}

/**
 * 查询申请详情
 * @param params
 * @returns {Promise<void>}
 */
export async function queryFileApplyDetail(params) {
  return request('/b/fileapply/query', {
    method: 'POST',
    data: params,
  });
}

/**
 * 新增外发申请
 * @param params
 * @returns {Promise<void>}
 */
export async function addOutApply(params) {
  return request('/b/fileapply/out/add', {
    method: 'POST',
    data: params,
  });
}
export async function addGroupApply(params) {
  return request('/b/fileapply/group/add', {
    method: 'POST',
    data: params,
  });
}

/**
 * 新增共享申请
 * @param params
 * @returns {Promise<void>}
 */
export async function addShareApply(params) {
  return request('/b/fileapply/share/add', {
    method: 'POST',
    data: params,
  });
}

/**
 * 新增流转申请
 * @param params
 * @returns {Promise<void>}
 */
export async function addFlowApply(params) {
  return request('/b/fileapply/flow/add', {
    method: 'POST',
    data: params,
  });
}

/**********************个人文件********************************/
// 查询我的文件
export async function queryMyFiles(params) {
  return request('/b/fileinfo/queryFileDirPageList', {
    method: 'post',
    data: params,
  });
}

// 查询目录
export async function queryFileDir(params) {
  return request('/b/filedir/query', {
    method: 'post',
    data: params,
  });
}

// 查询共享文件
export async function queryShareFiles(params) {
  return request('/b/fileinfo/querySharePageList', {
    method: 'post',
    data: params,
  });
}

/**
 * 设为常用
 * @param params
 * @returns {Promise<void>}
 */
export async function updateFileMostUse(params) {
  return request('/b/fileinfo/updateFileMostUse', {
    method: 'post',
    data: params,
  });
}

/**
 * 更新共享
 * @param params
 * @returns {Promise<void>}
 */
export async function updateFileShare(params) {
  return request('/b/fileinfo/updateFileShare', {
    method: 'post',
    data: params,
  });
}

/**
 * 上传文件
 * @param params
 * @returns {Promise<void>}
 */
export async function upload(params) {
  return request('/b/fileinfo/upload', {
    method: 'post',
    data: params,
    headers: {'Content-Type': 'multipart/form-data'},
  });
}

/**
 * 新建文件夹
 * @param params
 * @returns {Promise<void>}
 */
export async function addDir(params) {
  return request('/b/fileinfo/addDir', {
    method: 'post',
    data: params,
  });
}

export async function updateDir(params) {
  return request('/b/fileinfo/updateDir', {
    method: 'post',
    data: params,
  });
}

/**
 * 删除文件或文件夹
 * @param params
 * @returns {Promise<void>}
 */
export async function deleteFileOrDir(params) {
  return request('/b/fileinfo/deleteFileOrDir', {
    method: 'post',
    data: params,
  });
}

export async function deleteOutSideFileOrDir(params) {
  return request('/b/fileoutside/delete', {
    method: 'post',
    data: params,
  });
}

export async function copyFileToUpload(params) {
  return request('/b/fileoutside/copyFileToUpload', {
    method: 'post',
    data: params,
  });
}

export async function moveFileToUpload(params) {
  return request('/b/fileoutside/moveFileToUpload', {
    method: 'post',
    data: params,
  });
}

/**
 * addPreDownload预下载文件
 * @param params
 * @returns {Promise<void>}
 */
export async function addPreDownload(params) {
  return request('/b/fileinfo/addPreDownload', {
    method: 'post',
    data: params,
  });
}

/****
 * 个人文件下载申请
 * @param params
 * @returns {Promise<void>}
 */
export async function privateFilesDownload(params) {
  return request('/b/fileapply/priavatefiledownload/add', {
    method: 'post',
    data: params,
  });
}

export async function editApply(params) {
  return request('/b/fileapply/editApply/add', {
    method: 'post',
    data: params,
  });
}

/**
 * 获取文件编辑地址
 * @param params
 * @returns {Promise<void>}
 */
export async function getEditLinkPath(params) {
  return request('/b/onlineedit/getEditLinkPath', {
    method: 'post',
    data: params,
  });
}

/**文件预览地址**/
export async function getPreviewLinkPath(params) {
  return request('/b/preview/getPreviewPath', {
    method: 'post',
    data: params,
  });
}

/**外接文件预览**/
export async function getPreviewPathForOuter(params) {
  return request('/b/preview/getPreviewPathForOuter', {
    method: 'post',
    data: params,
  });
}

/**
 * 查询目录的树结构
 * @param params
 * @returns {Promise<void>}
 */

/**
 * 移动文件
 * @param params
 * @returns {Promise<void>}
 */
export async function copyFile(params) {
  return request('/b/fileinfo/copyFile', {
    method: 'post',
    data: params,
  });
}

export async function uploadFiles(params) {
  return request('/b/fileinfo/upload', {
    method: 'post',
    // processData: false,
    data: params,
    headers: {'Content-Type': 'multipart/form-data'},
  });
}

export async function uploadOutsideFiles(params) {
  return request('/b/fileoutside/uploadOutsideFiles', {
    method: 'post',
    // processData: false,
    data: params,
    headers: {'Content-Type': 'multipart/form-data'},
  });
}

export async function uploadFilesToGroup(params) {
  return request('/b/fileinfo/uploadByGroup', {
    method: 'post',
    // processData: false,
    data: params,
    // headers: {'Content-Type': 'multipart/form-data'},
  });
}


export async function applyAudit(params) {
  return request('/b/fileapply/audit', {
    method: 'post',
    data: params,
  });
}

// 我的审核------------star----------

// 文件审批列表
export async function approval(params) {
  return request('/b/fileapply/audit', {
    method: 'post',
    data: params,
  });
}

// 查询文件未审批列表
export async function queryNotPageList(params) {
  return request('/b/fileapproval/queryNotPageList', {
    method: 'post',
    data: params,
  });
}

// 查询文件已审批列表
export async function fileQueryPageList(params) {
  return request('/b/fileapproval/queryPageList', {
    method: 'post',
    data: params,
  });
}

// 我的审核------------end----------


// 下载列表-----------star---------

export async function filedownloadList(params) {
  return request('/b/filedownload/queryPageList', {
    method: 'post',
    data: params,
  });
}

export async function filedownloadDelete(params) {
  return request('/b/filedownload/delete', {
    method: 'post',
    data: params,
  });
}

export async function downloadFile(params) {
  return request('/b/filedownload/fileDownload', {
    method: 'post',
    data: params,
  });
}

export async function quickDownload(params) {
  return request('/b/filedownload/quickDownload', {
    method: 'post',
    data: params,
  });
}

export async function quickDownloadGroupFiles(params) {
  return request('/b/filedownload/group/quickDownload', {
    method: 'post',
    data: params,
  });
}

export async function quickDownloadShareFiles(params) {
  return request('/b/filedownload/share/quickDownload', {
    method: 'post',
    data: params,
  });
}

export async function setDownloaded(params) {
  return request('/b/filedownload/setDownloaded', {
    method: 'post',
    data: params,
  });
}

// 下载列表-----------end---------

/*外接文件*/

//下载申请外接文件
export async function addOutFileApply(params) {
  return request('/b/fileapply/share/add', {
    method: 'POST',
    data: params,
  });
}

export async function addPrivateFileDownloadApply(params) {
  return request('/b/fileinfo/querySharePageList', {
    method: 'post',
    data: params,
  });
}

export async function addGroupFileDownloadApply(params) {
  return request('/b/fileinfo/querySharePageList', {
    method: 'post',
    data: params,
  });
}

export async function queryMyReceive(params) {
  return request('/b/fileinfo/querySharePageList', {
    method: 'post',
    data: params,
  });
}

// 我的接受----------star-------------

export async function receivefilesList(params) {
  return request('/b/receivefiles/queryPageList', {
    method: 'post',
    data: params,
  });
}

export async function receivefilesDelete(params) {
  return request('/b/receivefiles/delete', {
    method: 'post',
    data: params,
  });
}


export async function queryDirTreeList(params) {
  return request('/b/fileinfo/queryDirTreeList', {
    method: 'post',
    data: params,
  });
}

// 移动确定
export async function moveReceiveFile(params) {
  return request('/b/receivefiles/moveFile', {
    method: 'post',
    data: params,
  });
}

// 移动确定
export async function movePrivateFile(params) {
  return request('/b/fileinfo/moveFile', {
    method: 'post',
    data: params,
  });
}

// 移动外接文件
export async function moveOutFileToPrivate(params) {
  return request('/b/fileoutside/moveOuterFile', {
    method: 'post',
    data: params,
  });
}

// 复制外接文件
export async function copyOutFileToPrivate(params) {
  return request('/b/fileoutside/copyOuterFile', {
    method: 'post',
    data: params,
  });
}

// 预览
export async function previewFile(params) {
  return request('/b/receivefiles/preview', {
    method: 'post',
    data: params,
  });
}

// 下载
export async function downloadFiles(params) {
  return request('/b/receivefiles/downloadFiles', {
    method: 'post',
    data: params,
  });
}

export async function queryDownloadStrategy(params) {
  return request('/b/filedownload/queryStrategyList', {
    method: 'post',
    data: params,
  });
}

// 下载
export async function downloadBwdaOnlineEdit(params) {
  return request('/b/common/downloadBwdaOnlineEdit', {
    method: 'post',
    data: params,
  });
}

// 查询自定义组
export async function queryGroupList(params) {
  return request('/b/filecommunal/queryList', {
    method: 'post',
    data: params,
  });
}


// 我的接受----------end-------------


// 我的申请-------star-----------
// 查询我的申请列表
export async function fileapplyList(params) {
  return request('/b/fileapply/queryPageList', {
    method: 'POST',
    data: params,
  });
}

export async function fileapplyDelete(params) {
  return request('/b/fileapply/delete', {
    method: 'POST',
    data: params,
  });
}

// 查询申请详情
export async function queryApplyDetail(params) {
  return request('/b/fileapply/queryApplyDetail', {
    method: 'POST',
    data: params,
  });
}

export async function applyMoveFile(params) {
  return request('/b/fileapply/moveFile', {
    method: 'POST',
    data: params,
  });
}

export async function downloadApplyFiles(params) {
  return request('/b/fileapply/downloadApplyFiles', {
    method: 'POST',
    data: params,
  });
}

export async function fileapplyPreivew(params) {
  return request('/b/fileapply/preivew', {
    method: 'POST',
    data: params,
  });
}

// 我的申请-------end-----------

/**************************公共文件start*********/
export async function queryFileDirByGroup(params) {
  return request('/b/fileinfo/queryFileDirByGroup', {
    method: 'POST',
    data: params,
  });
}


/**************************外接文件start*********/

/**
 * 查询外接文件列表
 * @param params
 * @returns {Promise<void>}
 */
export async function queryOutFileList(params) {
  return request('/b/fileoutside/queryList', {
    method: 'POST',
    data: params,
  });
}

/**
 * 查询外接FTP列表
 * @param params
 * @returns {Promise<void>}
 */
export async function queryOutFtpList(params) {
  return request('/b/fileoutside/queryOutFtpList', {
    method: 'POST',
    data: params,
  });
}

/**
 * 查询共享详情
 * @param params
 * @returns {Promise<void>}
 */
export async function queryShareDetail(params) {
  return request('/b/fileinfo/queryShareDetail', {
    method: 'POST',
    data: params,
  });
}

/**
 * 查询自定义组
 * @param params
 * @returns {Promise<void>}
 */
export async function queryGroupListByUsercode(params) {
  return request('/s/group/queryEnableList', {
    method: 'POST',
    data: params,
  });
}

export async function queryUserListByOrgId(params) {
  return request('/s/user/queryUserListByOrgId', {
    method: 'POST',
    data: params,
  });
}

export async function getSupportUploadFileList(params) {
  return request('/s/datadict/getSupportUploadFileList', {
    method: 'POST',
    data: params,
  });
}


// 查询数据字典列表,
export async function queryDatadictList(params) {
  return request('/s/datadict/queryPageList', {
    method: 'POST',
    data: params,
  });
}


// 查询数据字典列表,
export async function scan(params) {
  return request('/b/fileinfo/scan', {
    method: 'POST',
    data: params,
  });
}

// 获取协同人
export async function querySensitive(params) {
  return request('/b/jinku/querySensitive', {
    method: 'POST',
    data: params,
  });
}

// 获取短信授权码
export async function querySms(params) {
  return request('/b/jinku/querySms', {
    method: 'POST',
    data: params,
  });
}

// 验证
export async function checkSensitive(params) {
  return request('/b/jinku/checkSensitive', {
    method: 'POST',
    data: params,
  });
}


/**************************外接文件end*********/

/**
 * 查询操作权限
 * @param params
 * @returns {Promise<void>}
 */
export async function queryOptRight(params) {
  return request('/b/fileinfo/queryOptRight', {
    method: 'POST',
    data: params,
  });
}

/**
 * 查询文件扫描结果
 * @param params
 * @returns {Promise<void>}
 */
export async function queryScanTree(params) {
  // /b/fileinfo/queryScanTree
  return request('/b/fileinfo/queryScanListForC', {
    method: 'POST',
    data: params,
  });
}

/**
 * 查询首页文件库名称配置
 * @param params
 * @returns {Promise<void>}
 */
export async function queryFileHomePage(params) {
  return request('/b/fileinfo/queryFileHomePage', {
    method: 'POST',
    data: params,
  });
}

/**
 * 查询自定义组管理员
 * @param params
 * @returns {Promise<void>}
 */
export async function queryGroupAdmin(params) {
  return request('/s/org/queryGroupAdmin', {
    method: 'POST',
    data: params,
  });
}

/**
 * 查询是否安装保旺达在线编辑客户端，此请求较为特殊，是请求本地的url
 * @param params
 * @returns {Promise<void>}
 */
export async function queryBwdaEditAppState() {

  let url = "/BwdaOnlineEditServer";
  let params = {};
  params.json = '{\"function\":\"version\"}';
  return request(url, {
    method: 'POST',
    requestType: 'json',
    data: params,

  });
}
